package androidx.recyclerview.widget;

/**
 * 一个排序类，系统稍微封装了一下。   <br>
 * 你可以只关心数据排序逻辑。   <br>
 * 因为这个类帮你做了 一些 ui 方面刷新的操作 ，   <br>
 * 例如  mAdapter.notifyItemRangeChanged 等    <br>
 */
public abstract class SortedListAdapterCallback<T2> extends SortedList.Callback<T2> {

    final RecyclerView.Adapter mAdapter;


    public SortedListAdapterCallback(RecyclerView.Adapter adapter) {
        mAdapter = adapter;
    }

    @Override
    public void onInserted(int position, int count) {
        mAdapter.notifyItemRangeInserted(position, count);
    }

    @Override
    public void onRemoved(int position, int count) {
        mAdapter.notifyItemRangeRemoved(position, count);
    }

    @Override
    public void onMoved(int fromPosition, int toPosition) {
        mAdapter.notifyItemMoved(fromPosition, toPosition);
    }

    @Override
    public void onChanged(int position, int count) {
        mAdapter.notifyItemRangeChanged(position, count);
    }

    @Override
    public void onChanged(int position, int count, Object payload) {
        mAdapter.notifyItemRangeChanged(position, count, payload);
    }
}
